from ultralytics import YOLO

# 图片尺寸：900 * 500px
# 'train' and 'val' imgsz must be an integer, while 'predict' and 'export' imgsz may be 
# a [h, w] list or an integer, i.e. 'yolo export imgsz=640,480' or 'yolo export imgsz=640'

if __name__ == '__main__':
    # model = YOLO("yolo11n.yaml").load("yolo11n.pt")  # build from YAML and transfer weights
    model = YOLO("runs/detect/train4/weights/best.pt")

    # Export the model to ONNX format
    success = model.export(format="onnx", 
                           imgsz=[1024, 1280],
                           dynamic=False,
                           simplify=True,
                           batch=1,
                           nms=False,)
